import numpy as np
import pandas as pd
import os

os.chdir(r"C:\Users\Dreamer\Desktop\研究生\研一上\python课程作业\大作业")
#数据的导入与数据处理
def status1(x):
    if x>0:
        a=1
    else:
        a=0
    return a

def status2(x):
    if x<0:
        a=1
    else:
        a=0
    return a

data = pd.read_excel('申万行业指数一级行业.xlsx',header=1,index_col='时间').dropna(how='all').ffill()
data.index = pd.to_datetime(data.index)
industry_list = list(data.columns.values)
data

data1=data.shift(axis=0)
A_D=(data-data1)/data1
data2=A_D.fillna(0)
data3=data2.copy(deep=True)
data_r=data2.applymap(lambda x:status1(x))
data_f=data2.applymap(lambda x:status2(x))
data_r.to_csv("Data_test.csv")